Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add True-Client-IP custom header to be passed along to BAPI #298

Closed
wants to merge 1 commit into from

Conversation

NicolasLopes7
Copy link
Contributor

@NicolasLopes7 NicolasLopes7 commented May 29, 2024

This PR adds the True-Client-IP header on the custom headers map in order to pass it along our APIs. We are introducing request info on the webhook and that will enable us to know who has called other than the user-agent.

@NicolasLopes7 NicolasLopes7 requested a review from a team as a code owner May 29, 2024 18:49
@NicolasLopes7 NicolasLopes7 force-pushed the feat/add-true-client-ip-on-header branch from 6b0abf0 to 790d2c9 Compare May 29, 2024 18:50
@gkats
Copy link
Member

gkats commented May 30, 2024

@NicolasLopes7 Could you please provide more information on what this change is about, and why we need it/what problem it currently solves? Thanks!

clerk.go Outdated
@@ -169,6 +170,7 @@ func (h *CustomRequestHeaders) apply(req *http.Request) {
return
}
req.Header.Add("X-Clerk-Application", h.Application)
req.Header.Add("True-Client-IP", h.TrueClientIP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 This is a semi-standard header name and can potentially cause issues if it's being set on the request directly. Better use the X-Clerk- namespace here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! That makes sense!

@NicolasLopes7 NicolasLopes7 force-pushed the feat/add-true-client-ip-on-header branch from 790d2c9 to 1941c28 Compare May 31, 2024 14:26
@NicolasLopes7
Copy link
Contributor Author

@NicolasLopes7 Could you please provide more information on what this change is about, and why we need it/what problem it currently solves? Thanks!

Added on the description 👍

@@ -169,6 +170,7 @@ func (h *CustomRequestHeaders) apply(req *http.Request) {
return
}
req.Header.Add("X-Clerk-Application", h.Application)
req.Header.Add("X-Clerk-True-Client-IP", h.TrueClientIP)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 Perhaps the "True" portion of the name is a bit too much?

Suggested change
req.Header.Add("X-Clerk-True-Client-IP", h.TrueClientIP)
req.Header.Add("X-Clerk-Client-IP", h.ClientIP)

@@ -160,7 +160,8 @@ type Params interface {
// CustomRequestHeaders contains predefined values that can be
// used as custom headers in Backend API requests.
type CustomRequestHeaders struct {
Application string
Application string
TrueClientIP string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ How will this field be used?

The CustomHeaders struct is provided upon the Backend initialization and does not dynamically track values for every request.

See

CustomRequestHeaders: config.CustomRequestHeaders,

The test that's updated in this PR shows exactly this. The value of the x-clerk-true-client-ip header will always be "127.0.0.1" no matter where the request comes from.

Hope I'm not missing anything, but are we sure this PR solves our problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense @gkats, great catch! I'll sync with you tomorrow to understand how can I just pass the headers coming along from a request (if possible). Closing this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants